<include file="Public/min-header" />
<div class="wrapper">
    <include file="Public/breadcrumb" />
    <section class="content">
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 插件列表</h3>
                </div>
                <div class="panel-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a id="tab_plugin_payment" href="#tab_pay" data-toggle="tab">支付插件</a></li>
                        <li><a id="tab_plugin_login" href="#tab_login" data-toggle="tab">登录插件</a></li>
                        <li><a id="tab_plugin_shipping" href="#tab_shipping" data-toggle="tab">物流插件</a></li>
                    </ul>
                    <form method="post" id="addEditGoodsForm">
                        <div class="tab-content">

                            <div class="tab-pane active" id="tab_pay">
                                <div class="row">
                                    <volist name="payment" id="p">
                                        <div class="col-sm-2" style="width:260px;margin-top: 10px;">
                                            <div class="thumbnail">
                                                <img style="width:150px; height:60px;" src="/plugins/payment/{$p.code}/{$p.icon}" alt="...">
                                                <div class="caption">
                                                    <h4>{$p.name}</h4>
                                                    <p>{$p.desc}</p>
                                                    <if condition="$p.status eq 0">
                                                        <p><a onclick="installPlugin('{$p.type}', '{$p.code}', 1)" href="#" class="btn btn-primary" role="button">一键安装</a> </p>
                                                        <else />
                                                        <p><a onclick="installPlugin('{$p.type}', '{$p.code}', 0)" href="#" class="btn btn-danger" role="button">卸载</a>
                                                            <a href="{:U('Admin/Plugin/setting',array('type'=>$p['type'],'code'=>$p['code']))}" class="btn btn-primary" role="button">配置</a>
                                                        </p>
                                                    </if>
                                                </div>
                                            </div>
                                        </div>
                                    </volist>
                                </div>
                            </div>

                            <div class="tab-pane" id="tab_login">
                                <div class="row">
                                    <volist name="login" id="l">
                                        <div class="col-sm-2" style="width:260px;margin-top: 10px;">
                                            <div class="thumbnail">
                                                <img style="width:150px; height:60px;" src="/plugins/login/{$l.code}/{$l.icon}">
                                                <div class="caption">
                                                    <h4>{$l.name}</h4>
                                                    <p>{$l.desc}</p>
                                                    <if condition="$l.status eq 0">
                                                        <p><a onclick="installPlugin('{$l.type}', '{$l.code}', 1)" href="#" class="btn btn-primary" role="button">一键安装</a> </p>
                                                        <else />
                                                        <p><a onclick="installPlugin('{$l.type}', '{$l.code}', 0)" href="#" class="btn btn-danger" role="button">卸载</a> <a href="{:U('Admin/Plugin/setting',array('type'=>$l['type'],'code'=>$l['code']))}" class="btn btn-primary" role="button">配置</a></p>
                                                    </if>
                                                </div>
                                            </div>
                                        </div>
                                    </volist>
                                </div>
                            </div>

                            <div class="tab-pane" id="tab_shipping">
                                <div class="row">
                                    <volist name="shipping" id="l">
                                        <div class="col-sm-2" style="width:260px;margin-top: 10px;">
                                            <div class="thumbnail">
                                                <img style="width:150px; height:60px;" src="/plugins/shipping/{$l.code}/{$l.icon}">
                                                <div class="caption">
                                                    <h4>{$l.name}</h4>
                                                    <p>{$l.desc}</p>
                                                    <if condition="$l.status eq 0">
                                                        <p>
                                                            <a onclick="installPlugin('{$l.type}', '{$l.code}', 1)" href="#" class="btn btn-primary" role="button">一键安装</a>
                                                            <a onclick="if (confirm('确定要删除吗?'))
                                                                        del_shipping('{$l[\'code\']}');" href="#" class="btn btn-danger" role="button"><i class="fa fa-trash-o"></i></a>
                                                        </p>
                                                        <else />
                                                        <p>
                                                            <a onclick="installPlugin('{$l.type}', '{$l.code}', 0)" href="#" class="btn btn-danger" role="button">卸载</a>
                                                            <a href="{:U('Admin/Plugin/shippingList',array('type'=>'shipping','code'=>$l['code']))}" class="btn btn-primary" role="button">配置</a>
                                                            <!--<a href="{:U('Admin/Plugin/shippingPrint',array('type'=>'shipping','code'=>$l['code']))}" class="btn btn-primary" role="button">模板编辑</a>-->
                                                        </p>
                                                    </if>
                                                </div>
                                            </div>
                                        </div>
                                    </volist>
                                    <div style="width:260px;" class="col-sm-2">
                                        <div class="thumbnail" style="height:203px;">
                                            <img src="__PUBLIC__/images/wuliu.png" style="width:150px; height:100px;">
                                            <div class="caption">
                                                <p></p>
                                                <p></p>
                                                <p align="center">
                                                    <a class="btn btn-primary" href="/index.php/Admin/Plugin/addShipping">添加物流</a>
                                                </p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!--                            <div class="tab-pane" id="tab_function">
                                                            <div class="row">
                                                                <volist name="function" id="l">
                                                                    <div class="col-sm-2" style="width:260px;margin-top: 10px;">
                                                                        <div class="thumbnail">
                                                                            <img style="width:150px; height:60px;" src="/plugins/function/{$l.code}/{$l.icon}">
                                                                            <div class="caption">
                                                                                <h4>{$l.name}</h4>
                                                                                <p>{$l.desc}</p>
                                                                                <if condition="$l.status eq 0">
                                                                                    <p><a onclick="installPlugin('{$l.type}', '{$l.code}', 1)" href="#" class="btn btn-primary" role="button">一键安装</a> </p>
                                                                                    <else />
                                                                                    <p>
                                                                                        <a onclick="installPlugin('{$l.type}', '{$l.code}', 0)" href="#" class="btn btn-danger" role="button">卸载</a>
                                                                                    </p>
                                                                                </if>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </volist>
                                                            </div>
                                                        </div>-->

                            <div class="tab-pane" id="tab_cloud">
                                <table class="table table-bordered" id="goods_attr_table">
                                    <tr>
                                        <td>暂无:</td>
                                        <td>
                                            暂无
                                        </td>
                                    </tr>
                                </table>
                            </div>

                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
</div>
<script>
    $(document).ready(function () {
        var type = "{$type}";
        if (type !== '') {
            $('#tab_plugin_' + type).trigger('click');
        }
    });
    //插件安装(卸载)
    function installPlugin(type, code, type2) {
        var url = '/index.php?m=Admin&c=Plugin&a=install&type=' + type + '&code=' + code + '&install=' + type2;
        $.get(url, function (data) {
            var obj = JSON.parse(data);
            alert(obj.msg);
            //layer.alert(obj.msg, {icon: 2});  
            if (obj.status == 1) {
                window.location.href = '/index.php?m=Admin&c=Plugin&a=index&type=' + type;
            }
        });
    }
    // 删除物流
    function del_shipping(code) {
        $.ajax({
            type: "POST",
            url: "{:U('Admin/Plugin/delShipping')}", //+tab,
            dataType: "json",
            data: {code: code},
            success: function (data) {
                layer.alert(data.msg, {icon: 2}, function (index) {
                    layer.close(index);
                    //location.href = location.href;
                    location.reload();
                });

            }
        });
    }
</script>
</body>

</html>
